package com.xgit.iov.admin.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xgit.iov.admin.mapper.SysTenantMapper;
import com.xgit.iov.admin.service.ISysTenantService;
import com.xgit.iov.common.core.entity.SysTenant;
import com.xgit.iov.common.core.service.impl.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 租户Service业务层处理
 *
 * @author william
 * @date 2020-07-04
 */

@Service
public class SysTenantServiceImpl extends SuperServiceImpl<SysTenantMapper, SysTenant> implements ISysTenantService {

    @Autowired
    private SysTenantMapper sysTenantMapper;

    /**
     * 查询租户
     *
     * @param id 租户ID
     * @return 租户
     */
    @Override
    public SysTenant selectSysTenantById(Long id) {
        return sysTenantMapper.selectSysTenantById(id);
    }

    /**
     * 查询租户列表
     *
     * @param sysTenant 租户
     * @return 租户
     */
    @Override
    public IPage selectSysTenantPage(Page page, SysTenant sysTenant) {
        return sysTenantMapper.selectSysTenantPage(page,sysTenant);
    }

    /**
     * 新增租户
     *
     * @param sysTenant 租户
     * @return 结果
     */
    @Transactional
    @Override
    public int insertSysTenant(SysTenant sysTenant) {
        return sysTenantMapper.insert(sysTenant);
    }

    /**
     * 修改租户
     *
     * @param sysTenant 租户
     * @return 结果
     */
    @Transactional
    @Override
    public int updateSysTenant(SysTenant sysTenant) {
        return sysTenantMapper.updateById(sysTenant);
    }

    /**
     * 批量删除租户
     *
     * @param ids 需要删除的租户ID
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteSysTenantByIds(Long[] ids) {
        return sysTenantMapper.deleteBatchIds(CollUtil.toList(ids));
    }

}
